<template>
  <div class="app-container">
    <!--工具栏-->
    <div class="head-container">
      <div v-if="crud.props.searchToggle">
        <!-- 搜索 -->
        <label class="el-form-item-label">{{ $t('outbound.missionCode') }}</label>
        <el-input v-model="query.missionCode" clearable :placeholder="$t('outbound.missionCode')" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">{{ $t('outbound.missionStatus') }}</label>
        <el-select v-model="query.missionStatus" filterable :placeholder="$t('common.selectPlaceholder')" clearable style="width: 185px;" class="filter-item">
          <el-option
            v-for="item in dict.outbound_task_type"
            :key="item.id"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
        <label class="el-form-item-label">{{ $t('outbound.outBoundOrderId') }}</label>
        <el-input v-model="query.outBoundOrderId" clearable :placeholder="$t('outbound.outBoundOrderId')" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <label class="el-form-item-label">{{ $t('outbound.palletCode') }}</label>
        <el-input v-model="query.palletCode" clearable :placeholder="$t('outbound.palletCode')" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
        <rrOperation :crud="crud" />
      </div>
      <!--如果想在工具栏加入更多按钮，可以使用插槽方式， slot = 'left' or 'right'-->
      <crudOperation :permission="permission" />

      <!--表格渲染-->
      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
        <el-table-column type="selection" width="55" />
        <el-table-column prop="missionStatus" :label="$t('outbound.missionStatus')">
          <!-- <template slot-scope="scope">
            {{ dict.label.outbound_task_type[scope.row.missionStatus] }}
          </template> -->
        </el-table-column>
        <el-table-column prop="missionCode" :label="$t('outbound.missionCode')" />
        <el-table-column prop="outBoundOrderId" :label="$t('outbound.outBoundOrderId')" />
        <el-table-column prop="palletCode" :label="$t('outbound.palletCode')" />
        <el-table-column prop="source" :label="$t('warehouse.source')" />
        <el-table-column prop="destination" :label="$t('warehouse.destination')" />
        <el-table-column prop="createTime" :label="$t('warehouse.createTime')" />
        <el-table-column prop="startTime" :label="$t('warehouse.startTime')" />
        <el-table-column prop="finishTime" :label="$t('warehouse.finishTime')" />
        <el-table-column prop="priority" :label="$t('outbound.priority')" />
      </el-table>
      <!--分页组件-->
      <pagination />
    </div>
  </div>
</template>

<script>
import CRUD, { presenter, header, form, crud } from '@crud/crud'
import rrOperation from '@crud/RR.operation'
import crudOperation from '@crud/CRUD.operation'
import pagination from '@crud/Pagination'

const defaultForm = { id: null, missionStatus: null, palletCode: null, source: null, destination: null, createTime: null, startTime: null, finishTime: null, missionCode: null, outBoundOrderId: null, priority: null }
export default {
  name: 'OutBoundMission',
  components: { pagination, crudOperation, rrOperation },
  mixins: [presenter(), header(), form(defaultForm), crud()],
  dicts: ['outbound_task_type'],
  cruds() {
    return CRUD({ title: '出库任务', url: 'api/outBoundMission', idField: 'id', sort: 'id,desc', optShow: {
      add: false,
      edit: false,
      del: false,
      download: true,
      reset: true
    }, crudMethod: {}})
  },
  data() {
    return {
      permission: {
        add: ['admin', 'outBoundMission:add'],
        edit: ['admin', 'outBoundMission:edit'],
        del: ['admin', 'outBoundMission:del']
      },
      rules: {
      },
      queryTypeOptions: [
        { key: 'missionStatus', display_name: '任务状态' },
        { key: 'palletCode', display_name: '载盘编码' },
        { key: 'missionCode', display_name: '任务编码' },
        { key: 'outBoundOrderId', display_name: '出库单id' }
      ]
    }
  },
  mounted() {
    crud.toQuery
  },
  methods: {
    // 钩子：在获取表格数据之前执行，false 则代表不获取数据
    [CRUD.HOOK.beforeRefresh]() {
      return true
    }
  }
}
</script>

<style scoped>

</style>
